<template>
	<view class="content">
        <view class="u-p-b-20">
            <u-search bg-color="#fff" :show-action="false" v-model="keyword" shape="round" placeholder="请输入内容" @search="doSearch"></u-search>
        </view>
        
		<view class="list" v-for="(item,index) in list" :key="index">
			<view class="u-flex u-p-b-10">
				<view class="name">{{item.user_name}}</view>
				<view class="role">{{item.position}}</view>
			</view>
			<view class="list_tit u-p-b-10">
				所属机构：{{item.institution_name}}
			</view>
			<view class="list_tit">
				工资合计：{{item.wages}}元
			</view>
			<view class="btn" @click="$gTo('../wageManagement/details?id=' + item.id)">
				编辑
			</view>
		</view>
        
        <view style="height: 94rpx;padding-top: 30rpx;">
            <u-loadmore :status="status" v-if="status != 'loadmore'" />
        </view>
	</view>
</template>

<script>
    export default {
        data() {
            return {
                status: 'loadmore', //是否显示没有更多了
                page: 1,
                list: [], 
                keyword: '',
            }
        },
        onShow() {
            this.page = 1
            this.list = []
            this.status = 'loadmore'
            this.getList()
        },
        onReachBottom() {
        	if(this.page == 1){return}
        	this.getList()
        },
        methods: {
            doSearch() {
                this.page = 1
                this.list = []
                this.status = 'loadmore'
                this.getList()
            },
            
            // 获取列表
            getList() {
            	if (this.status == 'nomore') return;
            	this.status = 'loading';
            	this.$ajax('users_manage', {
            		user_token: this.$getSync('userToken'),
            		page: this.page,
            		limit: 10,
                    type: 2,//1人员管理 2工资管理 3考勤打卡
                    name: this.keyword,//搜索
            	}).then(ret => {
            		if (ret.success == 1000) {
            			if (ret.detail.data.length > 0) {
            				this.list = this.list.concat(ret.detail.data);
            				this.page++;
            				this.status = 'loadmore'
            			} else {
            				this.status = 'nomore'
            			}
            		} else {
            			this.$toast(ret.msg);
            		}
            	});
            },
        },
    }
</script>

<style>
	page{background-color: #f5f5f5!important;}
</style>

<style scoped>
.content {
		/* display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center; */
		/* border-top: 2rpx solid #ebebeb; */
		padding: 20rpx 20rpx 100rpx;
	}
	.search_box{
		width: 100%;
		height: 66rpx;
		border-radius: 33rpx;
		box-shadow: 0 0 2rpx #e3e3e3;
		background-color: #fff;
		padding: 0 28rpx;
		margin-bottom: 30rpx;
	}
	.s_icon{
		width: 27rpx;
		height: 27rpx;
		margin-right: 14rpx;
	}
	.s_input{
		flex: 1;
		height: 66rpx;
		font-size: 26rpx;
		line-height: 66rpx;
		color: #000;
	}
	.list{
		width: 100%;
		position: relative;
		border-radius: 10rpx;
		background-color: #fff;
		padding: 40rpx 32rpx;
		margin-bottom: 20rpx;
	}
	.name{
		font-size: 32rpx;
		/* line-height: 34rpx; */
		color: #000;
		font-weight: bold;
		margin-right: 20rpx;
        max-width: 65vw;
	}
	.role{
		width: fit-content;
		height: 34rpx;
		font-size: 22rpx;
		/* line-height: 34rpx; */
		color: #00a0e9;
		border-radius: 4rpx;
		background-color: #ddf0f9;
		padding: 0 12rpx;
	}
	.list_tit{
		font-size: 26rpx;
		/* line-height: 28rpx; */
		color: #000000;
	}
	.btn{
		width: 114rpx;
		height: 52rpx;
		border-radius: 26rpx;
		position: absolute;
		right: 32rpx;
		bottom: 40rpx;
		z-index: 1;
		font-size: 24rpx;
		line-height: 48rpx;
		color: #5f8fbe;
		text-align: center;
		border: 2rpx solid #5f8fbe;
	}
</style>
